<?php
/**
 * Created by PhpStorm.
 * User: Shen
 * Date: 2016/6/30
 * Time: 19:59
 */
//通过参数形式链接数据库

try{
    $dsn='mysql:host=localhost;dbname=test';
    $username = 'root';
    $passwd = '123456';
    $pdo=new PDO($dsn,$username,$passwd);
    var_dump($pdo);
}catch (PDOException $e){
    echo $e->getMessage();
}


echo '<hr />';

//通过uri的形式连接数据库
try{
    $dsn = 'uri:file://D:\phpStudy\WWW\LearningPHP\lesson_29_2016-06-30\dsn.txt';
    $username = 'root';
    $passwd = '123456';
    $pdo=new PDO($dsn,$username,$passwd);
    var_dump($pdo);
}catch(PDOException $e){
    echo $e->getMessage();
}

//通过配置文件连接数据库
//在php.ini中配置dsn






